package com.learnyou.server.xingzuo.dto.enums;

import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

@Getter
public enum AttendanceStatus {

    NORMAL("NORMAL", "到课"),
    LEAVE("LEAVE", "请假"),
    EXCHANGE("EXCHANGE", "缺席"),
    ;


    private String value;

    private String desc;


    AttendanceStatus(String value, String desc){
        this.value = value;
        this.desc = desc;
    }

    public static String getTextByValue(String value) {
        return Stream.of(AttendanceStatus.values())
                .filter(t-> Objects.equals(t.getValue(), value))
                .map(AttendanceStatus::getDesc)
                .findFirst()
                .orElse(NORMAL.getDesc())
                ;
    }
}
